package com.gg.user.gguser.controller;


import com.gg.user.gguser.service.GgSigningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 签约客户
 */

@RestController
@RequestMapping("/signing")
public class GgSigningController {

    @Autowired
    private GgSigningService ggSigningService;


    /**
     * 增加 从信息、商机 新增过来的
     *
     * id 移动过来的id
     * type 从哪里移动过来
     */
    @PostMapping("/addSignings")
    public Object addSignings(HttpServletResponse response, HttpServletRequest request, Integer id,Integer type) throws Exception {
        return ggSigningService.addSignings(response, request, id,type);
    }

    /**
     * 移除 信息、商机
     */
    @PostMapping("/removeSignings")
    public Object removeSignings(HttpServletResponse response, HttpServletRequest request, Integer id, Integer type) throws Exception {
        return ggSigningService.removeSignings(response, request, id, type);
    }

    /**
     * 查询 列表
     */
    @PostMapping("/getSigning")
    public Object getSigning(HttpServletResponse response, HttpServletRequest request, Integer page, Integer pageNumber, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "type", required = false) Integer type, @RequestParam(name = "state", required = false) Integer state, @RequestParam(name = "remarks", required = false) String remarks) throws Exception {
        return ggSigningService.getSigning(response, request, page, pageNumber, name, type, state, remarks);
    }

    /**
     * 删除签约
     */
    @PostMapping("/delectSignings")
    public Object delectSignings(HttpServletResponse response, HttpServletRequest request,Integer id) throws Exception{
        return ggSigningService.delectSignings(response,request,id);
    }

    /**
     * 增加签约
     */
    @PostMapping("/addSigningsAll")
    public Object addSigningsAll(HttpServletResponse response, HttpServletRequest request, String name, String sex, @RequestParam(name = "position", required = false) String position, String phone, @RequestParam(name = "mailbox", required = false) String mailbox, @RequestParam(name = "qq", required = false) String qq, @RequestParam(name = "weChat", required = false) String weChat, @RequestParam(name = "provid", required = false) String provid, @RequestParam(name = "cityid", required = false) String cityid, @RequestParam(name = "areaid", required = false) String areaid, @RequestParam(name = "address", required = false) String address, @RequestParam(name = "level", required = false) Integer level, @RequestParam(name = "state", required = false) Integer state, @RequestParam(name = "remarks", required = false) String remarks, @RequestParam(name = "username", required = false) String username, @RequestParam(name = "fax", required = false) String fax, @RequestParam(name = "contact", required = false) String contact) throws Exception {
        return ggSigningService.addSigningsAll(response, request, name, sex, position, phone, mailbox, qq, weChat, provid, cityid, areaid, address, level, state, remarks, username, fax, contact);
    }

    /**
     * 查看签约详情
     */
    @PostMapping("/getSigningsSelectItems")
    public Object getSigningsSelectItems(HttpServletResponse response, HttpServletRequest request, String token) throws IOException {
        return ggSigningService.getSigningsSelectItems(response, request, token);
    }


    /**
     * 修改签约
     */
    @PostMapping("/updateSignings")
    public Object updateSignings(HttpServletResponse response, HttpServletRequest request, String ggItemsToken, @RequestParam(name = "ggSName", required = false) String ggSName, @RequestParam(name = "ggSProvince", required = false)String ggSProvince,@RequestParam(name = "ggSCity", required = false) String ggSCity,@RequestParam(name = "ggSAreaid", required = false)String ggSAreaid, @RequestParam(name = "ggSDetailed", required = false)String ggSDetailed, @RequestParam(name = "ggSHandle", required = false)String ggSHandle, @RequestParam(name = "ggSContact", required = false)String ggSContact, @RequestParam(name = "ggSState", required = false)Integer ggSState, @RequestParam(name = "ggSLevel", required = false)Integer ggSLevel, @RequestParam(name = "ggSGender", required = false)String ggSGender, @RequestParam(name = "ggSPosition", required = false)String ggSPosition, String ggSTelephone, @RequestParam(name = "ggSFax", required = false)String ggSFax, @RequestParam(name = "ggSMailbox", required = false)String ggSMailbox, @RequestParam(name = "ggSQq", required = false)String ggSQq, @RequestParam(name = "ggSWechat", required = false)String ggSWechat, @RequestParam(name = "ggSZipcode", required = false)String ggSZipcode, @RequestParam(name = "ggSWebsite", required = false)String ggSWebsite,  @RequestParam(name = "ggSSource", required = false)String ggSSource) throws Exception {
        return ggSigningService.updateSignings(response, request, ggItemsToken, ggSName, ggSProvince, ggSCity, ggSAreaid, ggSDetailed, ggSHandle, ggSContact, ggSState, ggSLevel, ggSGender, ggSPosition, ggSTelephone, ggSFax, ggSMailbox, ggSQq, ggSWechat, ggSZipcode, ggSWebsite, ggSSource);
    }

    /**
     * 签约批量  移除 签约移入信息
     */
    @PostMapping("/removebuSigningsAll")
    public Object removebuSigningsAll(HttpServletResponse response, HttpServletRequest request,String listid, Integer type) throws Exception{
        return ggSigningService.removebuSigningsAll(response, request, listid, type);
    }

    /**
     * 签约批量  删除
     */
    @PostMapping("/delectbuSigningsAll")
    public Object delectbuSigningsAll(HttpServletResponse response, HttpServletRequest request,String listid) throws Exception{
        return ggSigningService.delectbuSigningsAll(response, request, listid);
    }

    /**
     * 增加备注
     */
}
